package com.chixing.day04_oop;

/**
 * 方法中的参数传递:
 *      1、值传递:   基本数据类型的值 被 复制了一份，有两个独立的值
 *      int a = 10;
 *      int b = a;+
 *      2、地址传递: 引用数据类型的赋值，指向同一个堆内存
 *      Car car1 = new Car(102);
 *      Car car2 = car1;
 *      car1 = null; 断开指针
 */


public class MethodDemo {

    // 值传递:基本数据类型的值 被 复制了一份，有两个独立的值
    public static void fun1(int n){ //n = x =10
        n = 20;
    }
    // 地址传递:引用数据类型的赋值，指向同一个堆内存
    public static void fun2(Car c){ //Car c = car;
        c.setCarName("AAA");
        c.setCarBrand("奔驰");
    }

    public static void fun3(int[] b){
        b[0] = 99;
    }

    public static void main(String[] args) {
        int x = 10;
        fun1(x);
        System.out.println("x = " + x);

        Car car = new Car(111,"new","宝马","黑色");
        fun2(car);
        System.out.println("car Name = " + car.getCarName());

        int[] a = {10,20,30};
        fun3(a);
        System.out.println("a[0] = " + a[0]);
    }
}
